/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package BLO;

import DAO.ProductsDAO;
import DTO.Products.Products;
import java.sql.SQLException;
import util.SupportUtil;

/**
 *
 * @author ThanhTai
 */
public class ProductsBLO {

    public void getTopSaleProducts(String xmlFilePath) {
        try {
            ProductsDAO dao = new ProductsDAO();
            Products products = dao.getTopSaleProduct();

            SupportUtil util = new SupportUtil();
            util.marshal(xmlFilePath, products);

        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void getNewProducts(String xmlFilePath) {
        try {
            ProductsDAO dao = new ProductsDAO();
            Products products = dao.getNewProduct();

            SupportUtil util = new SupportUtil();
            util.marshal(xmlFilePath, products);

        } catch (SQLException ex) {
            ex.printStackTrace();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }

    public void getAllProducts(String xmlPath) {
        try {
            ProductsDAO dao = new ProductsDAO();
            Products pro = new Products();
            pro = dao.getAllProduct();
            SupportUtil util = new SupportUtil();
            util.marshal(xmlPath, pro);
//        } catch (SQLException ex) {
//            ex.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
